package com.ebao.po.blog;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @desc 图片
 * @author snow
 * @date 2012-7-10
 */
@Entity
@Table(name = "T_Photo")
public class TPhoto implements Serializable {

	private static final long serialVersionUID = -8834944809820000636L;
	
	private Long id;
	private TAlbum album;		// 所属相册
	private String photoUrl;	// 图片地址
	private String photoName;	// 图片名称
	private String description;	// 图片说明
	private String uploadDate;	// 上传日期
	private List<TPhotoComment> photoComments = new ArrayList<TPhotoComment>();	// 图片评论
	// 图片访问记录暂不实现

	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(optional = false, targetEntity = TAlbum.class)
	@JoinColumn(name = "album_id")
	public TAlbum getAlbum() {
		return album;
	}

	public void setAlbum(TAlbum album) {
		this.album = album;
	}

	public String getPhotoUrl() {
		return photoUrl;
	}

	public void setPhotoUrl(String photoUrl) {
		this.photoUrl = photoUrl;
	}

	public String getPhotoName() {
		return photoName;
	}

	public void setPhotoName(String photoName) {
		this.photoName = photoName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(length = 19)
	public String getUploadDate() {
		return uploadDate;
	}

	public void setUploadDate(String uploadDate) {
		this.uploadDate = uploadDate;
	}

	@OneToMany(cascade = {CascadeType.ALL}, mappedBy = "photo", targetEntity = TPhotoComment.class)
	public List<TPhotoComment> getPhotoComments() {
		return photoComments;
	}

	public void setPhotoComments(List<TPhotoComment> photoComments) {
		this.photoComments = photoComments;
	}

}
